#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org

START=50

start() {
	enable=$(uci get cupsd.config.enabled 2>/dev/null)
	if [ $enable -eq 1 ]; then
	sed -i  's/Port [0-9]*/Port '"$(uci get cupsd.config.port)"'/g' /etc/cups/cupsd.conf
		mkdir -m 0755 -p /var/cache/cups
		mkdir -m 0755 -p /var/cups
		mkdir -m 0755 -p /var/spool/cups/tmp
		service_start /usr/sbin/cupsd
	fi
}

stop() {
	service_stop /usr/sbin/cupsd
	kill $(pidof cupsd) >/dev/null 2>&1 || killall -9 cupsd >/dev/null 2>&1
}

reload(){
	stop
	sleep 2
	start
	echo "cupsd Server has restarted."
}
